import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '@/views/layout/Layout'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
**/
export const constantRouterMap = [
  // {
  //   path: '/redirect',
  //   component: Layout,
  //   hidden: true,
  //   children: [{
  //     path: '/redirect/:path*',
  //     component: () => import('@/views/redirect/index')
  //   }]
  // },
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  {
    path: '',
    component: Layout,
    redirect: '/dashboard',
    hidden: false,
    children: [{
      path: 'dashboard',
      name: 'dashboard',
      meta: {
        title: '首页',
        icon: 'dashboard'
      },
      component: () => import('@/views/dashboard/index')
    }]
  }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({
    y: 0
  }),
  routes: constantRouterMap
})
export const asyncRouterMap = [{
  path: '/adminSys',
  component: Layout,
  name: 'adminSys',
  authority: 'adminSys',
  meta: {
    title: 'admin系统',
    icon: 'guide'
  },
  children: [{
      path: 'baseManager',
      component: () => import('@/views/admin/index'),//父亲路由 route-view
      name: 'baseManager',
      authority: 'baseManager',
      meta: {
        title: '基础配置管理',
        icon: 'example'
      },
      children: [{
        path: 'userManager',
        component: () => import('@/views/admin/user/index'),
        name: 'userManager',
        meta: {
          title: '用户管理'
        },
        authority: 'userManager'
      }, {
        path: 'menuManager',
        icon: 'category',
        component: () => import('@/views/admin/menu/index'),
        name: 'menuManager',
        meta: {
          title: '菜单管理'
        },
        authority: 'menuManager'
      }, {
        path: 'groupManager',
        icon: 'group_fill',
        component: () => import('@/views/admin/group/index'),
        name: 'groupManager',
        meta: {
          title: '角色权限管理'
        },
        authority: 'groupManager'
      }, {
        path: 'groupTypeManager',
        icon: 'fa-users',
        component: () => import('@/views/admin/groupType/index'),
        name: 'groupTypeManager',
        meta: {
          title: '角色类型管理'
        },
        authority: 'groupTypeManager'
      }, {
        path: 'gateLogManager',
        icon: 'viewlist',
        component: () => import('@/views/admin/gateLog/index'),
        name: 'gateLogManager',
        meta: {
          title: '操作日志管理'
        },
        authority: 'gateLogManager'
      }]
    },

    {
      path: 'authManager',
      component: () => import('@/views/auth/index'),
      name: 'authManager',
      icon: 'setting',
      meta: {
        title: '服务授权管理',
        icon: 'lock'
      },
      authority: 'authManager',
      children: [{
          path: 'serviceManager',
          component: () => import('@/views/auth/service/index'),
          name: 'serviceManager',
          meta: {
            title: '服务管理'
          },
          authority: 'serviceManager'
        }
      ]
    },
    {
      path: 'monitorManager',
      component: () => import('@/views/monitor/index'),
      name: 'monitorManager',
      icon: 'setting',
      meta: {
        title: '监控模块管理',
        icon: 'eye'
      },
      authority: 'monitorManager',
      children: [{
        path: 'serviceEurekaManager',
        component: () => import('@/views/monitor/eureka/index'),
        name: 'serviceEurekaManager',
        meta: {
          title: 'Eureka注册中心'
        },
        authority: 'serviceEurekaManager'
      }, {
        path: 'serviceMonitorManager',
        component: () => import('@/views/monitor/service/index'),
        name: 'serviceMonitorManager',
        meta: {
          title: '服务状态监控'
        },
        authority: 'serviceMonitorManager'
      }, {
        path: 'serviceZipkinManager',
        component: () => import('@/views/monitor/zipkin/index'),
        name: 'serviceZipkinManager',
        meta: {
          title: '服务链路监控'
        },
        authority: 'serviceZipkinManager'
      }]
    }
  ]
}]

// export const asyncRouterMap = [
//   {
//   path: '/baseManager',
//   component: Layout,
//   name: 'baseManager',
//   icon: 'setting',
//   authority: 'baseManager',
//   meta: {
//     title: '基础配置管理',
//     icon: 'setting'
//   },
//   children: [{
//     path: 'userManager',
//     icon: 'user',
//     component: () => import('@/views/admin/user/index'),
//     name: 'userManager',
//     meta: {
//       title: '用户管理',
//       icon: 'user'
//     },
//     authority: 'userManager'
//   }, {
//     path: 'menuManager',
//     icon: 'category',
//     component: () => import('@/views/admin/menu/index'),
//     name: 'menuManager',
//     meta: {
//       title: '菜单管理',
//       icon: 'category'
//     },
//     authority: 'menuManager'
//   }, {
//     path: 'groupManager',
//     icon: 'group_fill',
//     component: () => import('@/views/admin/group/index'),
//     name: 'groupManager',
//     meta: {
//       title: '角色权限管理',
//       icon: 'group_fill'
//     },
//     authority: 'groupManager'
//   }, {
//     path: 'groupTypeManager',
//     icon: 'fa-users',
//     component: () => import('@/views/admin/groupType/index'),
//     name: 'groupTypeManager',
//     meta: {
//       title: '角色类型管理',
//       icon: 'category'
//     },
//     authority: 'groupTypeManager'
//   }, {
//     path: 'gateLogManager',
//     icon: 'viewlist',
//     component: () => import('@/views/admin/gateLog/index'),
//     name: 'gateLogManager',
//     meta: {
//       title: '操作日志管理',
//       icon: 'category'
//     },
//     authority: 'gateLogManager'
//   }]
// },

// {
//   path: '/authManager',
//   component: Layout,
//   name: 'authManager',
//   icon: 'setting',
//   meta: {
//     title: '服务授权管理',
//     icon: 'setting'
//   },
//   authority: 'authManager',
//   children: [{
//     path: 'serviceManager',
//     component: () => import('@/views/auth/service/index'),
//     name: 'serviceManager',
//     meta: {
//       title: '服务管理',
//       icon: 'category'
//     },
//     authority: 'serviceManager'
//   },
//   {
//     path: 'serviceEe',
//     component: () => import('@/views/monitor/eureka/index'),
//     name: 'serviceEe',
//     meta: {
//       title: 'Eureka',
//       icon: 'category'
//     },
//     authority: 'serviceEe'
//   }
//   ]
// },

// {
//   path: '/monitorManager',
//   component: Layout,
//   name: 'monitorManager',
//   icon: 'setting',
//   meta: {
//     title: '监控模块管理',
//     icon: 'category'
//   },
//   authority: 'monitorManager',
//   children: [{
//     path: 'serviceEurekaManager',
//     component: () => import('@/views/monitor/eureka/index'),
//     name: 'serviceEurekaManager',
//     meta: {
//       title: 'Eureka注册中心',
//       icon: 'category'
//     },
//     authority: 'serviceEurekaManager'
//   }, {
//     path: 'serviceMonitorManager',
//     component: () => import('@/views/monitor/service/index'),
//     name: 'serviceMonitorManager',
//     meta: {
//       title: '服务状态监控',
//       icon: 'category'
//     },
//     authority: 'serviceMonitorManager'
//   }, {
//     path: 'serviceZipkinManager',
//     component: () => import('@/views/monitor/zipkin/index'),
//     name: 'serviceZipkinManager',
//     meta: {
//       title: '服务链路监控',
//       icon: 'category'
//     },
//     authority: 'serviceZipkinManager'
//   }]
// }
// ]
